/*
 * Copyright 2013-2015 the original author or authors.
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package com.xdtech.coder.vo;

import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;

import com.xdtech.coder.model.ModelTableMapped;
import com.xdtech.core.orm.utils.BeanUtils;
import com.xdtech.web.freemark.item.GridColumn;

/**
 * 
 * @author max.zheng
 * @create 2016-3-1下午11:51:36
 * @since 1.0
 * @see
 */
public class ModelTableMappedItem implements Serializable
{
	private static final long serialVersionUID = 1L;
	
	private Long id;
	@GridColumn(title="映射类型",width=250,dictionaryCode="MODEL_MAPPED_TYPE")
	private String mappedType;
	@GridColumn(title="映射表",width=250,javaFormatter="codeCreaterController#createComboBox")
	private String mappedBy;
	private String mappedByModel;
	

	public Long getId() {
		return id;
	}

	public void setId(Long id) {
		this.id = id;
	}

	public String getMappedBy() {
		return mappedBy;
	}

	public void setMappedBy(String mappedBy) {
		this.mappedBy = mappedBy;
	}

	public String getMappedType() {
		return mappedType;
	}

	public void setMappedType(String mappedType) {
		this.mappedType = mappedType;
	}

	public String getMappedByModel() {
		return mappedByModel;
	}

	public void setMappedByModel(String mappedByModel) {
		this.mappedByModel = mappedByModel;
	}

	public static ModelTableMappedItem createItem(ModelTableMapped modelTableMapped) {
		ModelTableMappedItem modelTableMappedItem = new ModelTableMappedItem();
		BeanUtils.copyProperties(modelTableMappedItem, modelTableMapped);
		//自定义属性设置填充
		return modelTableMappedItem;
	}
	/**
	 * 根据model集合创建vo集合
	 * 
	 * @author max
	 * @return
	 */
	public static List<ModelTableMappedItem> createItems(List<ModelTableMapped> modelTableMappeds) {
		List<ModelTableMappedItem> modelTableMappedItems = new ArrayList<ModelTableMappedItem>();
		for (ModelTableMapped mtm : modelTableMappeds) {
			modelTableMappedItems.add(createItem(mtm));
		}
		return modelTableMappedItems;
	}
	
}
